package com.totoro.tygeneratedragonblock.enums;

import com.totoro.tygeneratedragonblock.executor.itemmatch.ItemMatchExecutor;
import com.totoro.tygeneratedragonblock.executor.itemmatch.impl.ContainMatchExecutor;
import com.totoro.tygeneratedragonblock.executor.itemmatch.impl.DefaultMatchExecutor;
import com.totoro.tygeneratedragonblock.executor.itemmatch.impl.EqualsMatchExecutor;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;

/**
 * @author Totoro
 * @version 0.1.0
 * @date 2025/8/10 - 19:22
 * @description
 **/
@AllArgsConstructor
public enum ItemMatchEnum {
    EQUALS("equals", new EqualsMatchExecutor()),
    CONTAIN("contain", new ContainMatchExecutor()),
    DEFAULT("default", new DefaultMatchExecutor());

    @Getter private final String matchType;
    @Getter private final ItemMatchExecutor itemMatchExecutor;

    public static ItemMatchEnum getItemMatchEnum(String matchKeyword) {
        for (ItemMatchEnum itemMatchEnum : values()) {
            if(matchKeyword.contains(itemMatchEnum.matchType)) {
                return itemMatchEnum;
            }
        }
        return DEFAULT;
    }
}
